<template>
    <div class="tfpwdbox">
        <div class="tfpwdbox_form">
            <span class="tfpwd_title">请输入支付密码</span>
            <div class="tfpwd_con">
                <input class="tfpwd_input1" v-foces="focesindex" type="password" v-model="pwd1">
                <input class="tfpwd_input2" v-foces="focesindex" type="password" v-model="pwd2">
                <input class="tfpwd_input3" v-foces="focesindex" type="password" v-model="pwd3">
                <input class="tfpwd_input4" v-foces="focesindex" type="password" v-model="pwd4">
                <input class="tfpwd_input5" v-foces="focesindex" type="password" v-model="pwd5">
                <input class="tfpwd_input6" v-foces="focesindex" type="password" v-model="pwd6">
            </div>
        </div>
        <div class="tfp_closepwd" @click="e_closepwdbox"></div>
    </div>
</template>

<script>
import sha256 from 'js-sha256'
import { vpost, sonpost, fpost, gpost, vlink } from '@api/axios'
import { tokenPost, jtpost, gtpost, tokenLink, jtget } from '@api/axiosByToken'
export default {
	name: 'tfpwdbox',
	data() {
		return {
			focesindex: 1,
			pwd1: '',
			pwd2: '',
			pwd3: '',
			pwd4: '',
			pwd5: '',
			pwd6: '',
		}
	},
	props: {
		carryData: {
			type: Object
		}
	},
	watch: {
		pwd1(newIp1) {
			if (this.pwd1) {
				this.focesindex = 2
			}
		},
		pwd2(newIp1) {
			if (this.pwd2) {
				this.focesindex = 3
			}
		},
		pwd3(newIp1) {
			if (this.pwd3) {
				this.focesindex = 4
			}
		},
		pwd4(newIp1) {
			if (this.pwd4) {
				this.focesindex = 5
			}
		},
		pwd5(newIp1) {
			if (this.pwd5) {
				this.focesindex = 6
			}
		},
		pwd6(newIp1) {
			if (this.pwd6) {
				this.dotrans()
			}
		},
	},
	components: {},

	computed: {},

	methods: {
		// 关闭密码框
		e_closepwdbox() {
			this.$emit('closepwdbox', false)
		},
		// 执行密码操作
		dotrans() {
			let paypwd = sha256(
				this.pwd1 +
					this.pwd2 +
					this.pwd3 +
					this.pwd4 +
					this.pwd5 +
					this.pwd6,
			)
			let key = 'password'
			this.carryData[key] = paypwd
			this._sendDotrans(this.carryData)
			// this.$Message.success('转账成功')
			// 转账成功 关闭密码框
			this.$emit('closepwdbox', false)
		},
		// 执行发送
		_sendDotrans(carryData) {
			this.$store.state.loadding = true
			tokenPost(tokenLink.carry, carryData).then(re => {
				this.$store.state.loadding = false
				if (re.status === 0) {
					this.$router.push('/self')
				} else {
					this.$Message.success(re.msg)
				}
			})
		}
	},

	mounted() {},
}
</script>